//
//  IFIndexIconCell.m
//  chanlin
//
//  Created by Ryan on 14-11-9.
//  Copyright (c) 2014年 chanlin. All rights reserved.
//

#import "IFIndexIconCell.h"
#import "UIView+Utils.h"
#import "UIImageView+WebCache.h"

@implementation IFIndexIconCell

- (void)uiInit{
    [super uiInit];
    
    _thumbnailImgView = [[UIImageView alloc] initWithFrame:CGRectMake(cellEdgeCap, cellEdgeCap,cellThumbnailWidth, cellThumbnailHeight)];
    
    [self.baseView  addSubview:_thumbnailImgView];
    self.titleLabel.left = self.anco.left = self.styleIcon.left = cellEdgeCap + cellThumbnailWidth + cellTitleThumbnailCap;
    self.titleLabel.width = cellShortTitleWidth;
    // self.liveStatus.left = self.styleIcon.right + 3.f;
    
}

- (void)setPlayVideo:(BOOL)isPlay{
    if(isPlay &&self.thumbnailImgView){
        if(!self.playIcon){
            self.playIcon=[[UIImageView alloc] init];
            self.playIcon.image=[UIImage imageNamed:@"doc_playImage.png"];
            self.playIcon.frame=CGRectMake(5, self.thumbnailImgView.height-30.f, 23.f, 23.f);
            [self.thumbnailImgView addSubview:self.playIcon];
        }
        
        self.playIcon.hidden=NO;
    }else{
        self.playIcon.hidden=YES;
    }
}

- (void)loadData:(CLList *)newsList{
    [super loadData:newsList];
    [self.thumbnailImgView sd_setImageWithURL:[NSURL URLWithString:newsList.thumnail]
                             placeholderImage:[UIImage imageNamed:@"index_thumbnail.png"]];
}

- (void)loadTopicData:(CLTopic *)newsList{
    [super loadTopicData:newsList];
    [self.thumbnailImgView sd_setImageWithURL:[NSURL URLWithString:newsList.thumnail]
                             placeholderImage:[UIImage imageNamed:@"index_thumbnail.png"]];
}

- (void)loadCollect:(CLCollect *)collect{
    [super loadCollect:collect];
    [self.thumbnailImgView sd_setImageWithURL:[NSURL URLWithString:collect.thumnail]
                             placeholderImage:[UIImage imageNamed:@"index_thumbnail.png"]];

}

- (void)loadDic:(NSDictionary *)dic{
    [super loadDic:dic];
    NSString *url=[dic sgrGetStringForKey:@"titlepic"];
    if(_isStrNULL(url)) return;
    [self.thumbnailImgView sd_setImageWithURL:[NSURL URLWithString:url]
                             placeholderImage:[UIImage imageNamed:@"index_thumbnail.png"]];
}

@end
